package com.timeDeal.servlet;









import com.alibaba.druid.util.StringUtils;
import com.timeDeal.bean.PageList;
import com.timeDeal.bean.UserBean;
import com.timeDeal.bean.XuqiufabuBean;
import com.timeDeal.service.UserService;
import com.timeDeal.service.XuqiuService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;


/**
 * Created by Administrator on 2016/7/24.
 */

public class WodeJiaoyiServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String  currentpage =request.getParameter("currentpage")  ;
        String flag = org.apache.commons.lang3.StringUtils.defaultString(request.getParameter("flag"),"0");
        System.out.println(currentpage);
        UserBean  loginuser =   (UserBean) request.getSession().getAttribute("USER") ;
        currentpage = StringUtils.equals(currentpage,null)?"1":currentpage ;
        PageList pageList =  new PageList() ;
        int cu = Integer.valueOf(currentpage) ;
        UserService userService = new UserService();
        if(StringUtils.equals(flag,"0")){
            pageList = userService.getJiaoyiById(cu ,loginuser.getYonghuid()) ;
            request.setAttribute("pageList", pageList);
            request.setAttribute("currentpage", currentpage);
            request.getRequestDispatcher("/user/wodejiaoyi.jsp").forward(request,response);
        }
       else {
            pageList = userService.getJiaoyiByIdandShijian(cu, loginuser.getYonghuid());
            request.setAttribute("pageList", pageList);
            request.setAttribute("currentpage", currentpage);
            request.getRequestDispatcher("/user/shijianchushou/wodejiaoyi.jsp").forward(request, response);
        }





    }
}
